

package testpluginfile.popup.service;

import static org.junit.Assert.assertEquals;

import java.io.BufferedReader;
import java.io.StringReader;

import org.junit.Test;


public class ExpandFileMotsTest {

	
	@Test	
	public void testGetNumLigneCasSimple() {
		int idTest = ExpandFileMots.getNumLigne("m123");
		assertEquals(123,idTest,0);
	}
	
	@Test	
	public void testGetNumLigneCasnMots() {
		int idTest = ExpandFileMots.getNumLigne("m1234 1456 mzaza");
		assertEquals(1234,idTest,0);
	}

	@Test	
	public void testGetNumLigneCasTiret() {
		int idTest = ExpandFileMots.getNumLigne("m012-a");
		assertEquals(12,idTest,0);
	}

	@Test	
	public void testGetNumLigneNonPassant() {
		int idTest = ExpandFileMots.getNumLigne("totototo");
		assertEquals(-1,idTest,0);
	}	

	@Test	
	public void testGetNumLigneNonPassantVide() {
		int idTest = ExpandFileMots.getNumLigne("");
		assertEquals(-1,idTest,0);
	}
	
	@Test	
	public void testGetMaxCasSimple() {
		String s= "m125   \nm555 \nm077"; // your String
		StringReader sr= new StringReader(s); // wrap your String
		BufferedReader br= new BufferedReader(sr); // wrap your StringReader		
		int idTest = ExpandFileMots.getMaxNumLigne(br);
		assertEquals(555,idTest,0);
	}	
	
	@Test	
	public void testFormateCasSimple() {		
		int idTest = 100;
		String nbformate = ExpandFileMots.getNumeroFormate(idTest);
		assertEquals("00100",nbformate);
		assertEquals("00000",ExpandFileMots.getNumeroFormate(0));
	}	
		
}

